<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :xl="6" :lg="6" :md="6" :sm="24">
            <a-form-item label="订单编号">
              <el-input placeholder="请输入订单编号" v-model="queryParam.orderSn" style="width: 100%"></el-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="12">
            <a-form-item label="创建时间">
              <el-date-picker
                type="daterange"
                range-separator="~"
                start-placeholder="开始"
                end-placeholder="结束"
                placeholder="选择日期"
                @blur="formatD(form.date)"
                v-model="form.date"
                style="width: 100%;"
                value-format="yyyy-MM-dd"
              ></el-date-picker>
            </a-form-item>
            <!--            <j-date placeholder="开始日期" v-model="queryParam.date" style="width: 100%"></j-date>-->
          </a-col>

          <!--          <a-col :xl="3" :lg="7" :md="8" :sm="24">
                      <j-date placeholder="选择日期" v-model="queryParam.time" style="width: 100%"></j-date>
                    </a-col>-->

          <a-col :xl="6" :lg="6" :md="6" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="form.date = '';searchReset()" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!--table区域-begin-->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>

        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="30px" alt=""
               style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a-menu-item style="display: inline;margin-left: 10px">
            <a
              @click="$router.push({path:'/orderCenter/FactoryTeamProductDetail',query:{order:record.orderSn,product:record.productId}})">查看详情</a>
            <a style="margin-left: 8px;"
               @click="$router.push({path:'/orderCenter/SingleProductFactoryCB',query:{order:record.orderSn,product:record.productId}})">成本项</a>
          </a-menu-item>
        </span>
      </a-table>
    </div>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import {mixinDevice} from '@/utils/mixin'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import JDate from '@/components/jeecg/JDate.vue'

export default {
  name: 'Fabric',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    JDate
    // LgyxCreditRateModal
  },
  data() {
    return {
      form: {
        date: ''
      },
      labelCol: {span: 4},
      wrapperCol: {span: 14},
      groupName: '', // 组名称
      GroupPrice: '',// 组价格
      groupID: '', // 选中的组ID
      remake: '',// 组备注
      visible: false, // 新增弹框的显示
      visible2: false, // 编辑弹框的显示
      description: '面料订单',
      fabricOrderDetail: [], // 当前的面料订单详情
      orderDetail: {}, // 订单详情
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '订单编号',
          align: "center",
          dataIndex: 'orderSn'
        },
        /*{
          title: '产品编号',
          align: "center",
          dataIndex: 'productId'
        },*/
        {
          title: '品类名称',
          align: "center",
          dataIndex: 'plName'
        },
        {
          title: '品类编号',
          align: "center",
          dataIndex: 'plCode'
        },
        {
          title: '版号名称',
          align: "center",
          dataIndex: 'bhName'
        },
        {
          title: '版号',
          align: "center",
          dataIndex: 'bhCode'
        },
        {
          title: '工艺',
          align: "center",
          dataIndex: 'gylx'
        },
        {
          title: '接单时间',
          align: "center",
          dataIndex: 'createTime'
        },
        /*{
          title: '状态',
          align: "center",
          dataIndex: 'status'
        },*/
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          width: 147,
          scopedSlots: {customRender: 'action'}
        }
      ],
      url: {
        list: '/OrderFactoryController/listFactorySingleOrder?orderType=2',
      },
      dictOptions: {},
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {

    formatD(array) {
      this.queryParam.date = array[0]
      this.queryParam.enddate = array[1]
    },

    gotoFabricList(groupID) { // 页面跳转
      this.$router.push({
        path: '/fabric/fabricList',
        query: {
          group: groupID
        }
      })
    },

    initDictConfig() {
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';

.fabricName {
  margin-left: 10px;
  margin-top: 10px;
  width: auto;
  display: block !important;
  background: #2d2d2d;
  color: #ffe56d;
  text-align: center;
  border-radius: 3px;
}

.fabigtitle {
  height: 34px;
  width: 200px;
  text-align: left;
}

.fabigcontent {
  height: 34px;
  width: 200px;
  text-align: right;
}

.fatitle {
  height: 34px;
  width: 82px;
  background: rgb(242 242 242);
  text-align: center;
}

.facontent {
  width: 180px;
  overflow: hidden;
  text-align: center;
}
</style>